//
//  RepairTypeSelectView.m
//  ICrEAM
//
//  Created by Cty on 2016/11/02.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "RepairTypeSelectView.h"
#import "ICrEAMTool.h"
#define STARTLEFT ActualWidth(155)
#define STARTTOP ActualWidth(110)
#define MARGINRIGHT ActualWidth(10)
#define MARGINTOP ActualWidth(30)
#define TITLELEFT ActualWidth(272)

@interface RepairTypeSelectView()

@property (nonatomic, assign) int type;

@property (nonatomic,strong) NSMutableArray *currentSelectedData;


//常规保养
@property(nonatomic,strong)UIButton *button00;
@property(nonatomic,strong)UIButton *button01;
@property(nonatomic,strong)UIButton *button02;

//一般维修
@property(nonatomic,strong)UIButton *button10;
@property(nonatomic,strong)UIButton *button11;
@property(nonatomic,strong)UIButton *button12;
@property(nonatomic,strong)UIButton *button13;

//质量担保维修
@property(nonatomic,strong)UIButton *button20;
@property(nonatomic,strong)UIButton *button21;
@property(nonatomic,strong)UIButton *button22;
@property(nonatomic,strong)UIButton *button23;
@property(nonatomic,strong)UIButton *button24;

//内部维修
@property(nonatomic,strong)UIButton *button30;
@property(nonatomic,strong)UIButton *button31;
@property(nonatomic,strong)UIButton *button32;
@property(nonatomic,strong)UIButton *button33;
@property(nonatomic,strong)UIButton *button34;

//召回活动
@property(nonatomic,strong)UIButton *button40;
@property(nonatomic,strong)UIButton *button41;

//事故车维修
@property(nonatomic,strong)UIButton *button50;

//服务活动
@property(nonatomic,strong)UIButton *button60;

@property (nonatomic, strong) NSMutableArray *allButtons;
@property (nonatomic, strong) NSMutableArray *selectedIndexs;

@property (nonatomic, assign) BOOL isGetCar;

@end

@implementation RepairTypeSelectView

+ (instancetype)creatSelectViewWithFrame:(CGRect)frame andSelectedData:(NSMutableArray *)selected andGetCar:(BOOL)isGetCar{
    RepairTypeSelectView *repairTypeView = [[RepairTypeSelectView alloc]initWithFrame:frame andSelectedData:selected type:0];
    repairTypeView.isGetCar = isGetCar;
    return repairTypeView;
}

+ (instancetype)creatSelectViewOtherWithFrame:(CGRect)frame andSelectedData:(NSMutableArray *)selected{
    return [[RepairTypeSelectView alloc]initWithFrame:frame andSelectedData:selected type:1];
}

- (instancetype)initWithFrame:(CGRect)frame andSelectedData:(NSMutableArray *)selected type:(int)type{
    
    self = [super initWithFrame:frame];
    
    if(self){
        //传入已选择项目
        if(selected != nil)
            self.currentSelectedData = selected;
        
        [self setupViews:type];
        
    }
    return self;
}

- (void)setupViews:(int)type{
    self.type = type;
    self.backgroundColor = BackgroundColor_White;
    BorderWidth(self, 1.0);
    BorderColor(self, BorderColor_Gray_Hex);
    //维修类型title
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(TITLELEFT, ActualHeight(28), ActualWidth(100), ActualHeight(25))];
    title.textColor = TitleColor;
    title.font = NaviFont;
    title.text = @"维修类型";
    [self addSubview:title];
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(ActualWidth(2), title.bottomEdge+ActualHeight(20), ActualWidth(598), ActualHeight(1))];
    
    line.backgroundColor = BackgroundColor_Gray;
    [self addSubview:line];
    
    //保养
    UILabel *title0 = [[UILabel alloc]initWithFrame:CGRectMake(0, STARTTOP, ActualWidth(140), ActualHeight(38))];
    title0.textColor = Color(0xA1A1A1);
    title0.textAlignment = NSTextAlignmentRight;
    title0.font = NaviFont;
    title0.text = @"保养";
    [self addSubview:title0];
    
    //一般维修
    UILabel *title1 = [[UILabel alloc]initWithFrame:CGRectMake(0, title0.bottomEdge+MARGINTOP, ActualWidth(140), ActualHeight(38))];
    title1.textColor = Color(0xA1A1A1);
    title1.textAlignment = NSTextAlignmentRight;
    title1.font = NaviFont;
    title1.text = @"一般维修";
    [self addSubview:title1];
    
    //质量担保维修
    UILabel *title2 = [[UILabel alloc]initWithFrame:CGRectMake(0, title1.bottomEdge+MARGINTOP, ActualWidth(140), ActualHeight(38))];
    title2.textColor = Color(0xA1A1A1);
    title2.textAlignment = NSTextAlignmentRight;
    title2.font = NaviFont;
    title2.text = @"质量担保维修";
    if(type == 0)
        [self addSubview:title2];
 
    //内部维修
    UILabel *title3 = [[UILabel alloc]initWithFrame:CGRectMake(0, title2.bottomEdge+MARGINTOP, ActualWidth(140), ActualHeight(38))];
    title3.textColor = Color(0xA1A1A1);
    title3.textAlignment = NSTextAlignmentRight;
    title3.font = NaviFont;
    title3.text = @"内部维修";
    if(type == 0)
        [self addSubview:title3];
    
    //事故车维修
    UILabel *title5 = [[UILabel alloc]initWithFrame:CGRectMake(0, title3.bottomEdge+MARGINTOP, ActualWidth(140), ActualHeight(38))];
    title5.textColor = Color(0xA1A1A1);
    title5.textAlignment = NSTextAlignmentRight;
    title5.font = NaviFont;
    title5.text = @"事故车维修";
    if(type == 0)
        [self addSubview:title5];
    
    //召回行动
    UILabel *title4 = [[UILabel alloc]initWithFrame:CGRectMake(0, title5.bottomEdge+MARGINTOP, ActualWidth(140), ActualHeight(38))];
    title4.textColor = Color(0xA1A1A1);
    title4.textAlignment = NSTextAlignmentRight;
    title4.font = NaviFont;
    title4.text = @"召回行动";
    if(type == 0)
        [self addSubview:title4];
    
    //服务活动
    UILabel *title6 = [[UILabel alloc]initWithFrame:CGRectMake(0, title4.bottomEdge+MARGINTOP, ActualWidth(140), ActualHeight(38))];
    title6.textColor = Color(0xA1A1A1);
    title6.textAlignment = NSTextAlignmentRight;
    title6.font = NaviFont;
    title6.text = @"服务活动";
    [self addSubview:title6];
    if(type == 1)
        title6.frame = CGRectMake(0, title1.bottomEdge+MARGINTOP, ActualWidth(140), ActualHeight(38));
    
    
    [self addSubview:self.button00];
    if(type == 0)
        [self addSubview:self.button01];
    [self addSubview:self.button02];
    
    [self addSubview:self.button10];
    if(type == 0)
    {
        [self addSubview:self.button11];
        [self addSubview:self.button12];
        if ([ICrEAMTool isVW]){
            [self addSubview:self.button13];
        }
    }
    
    if(type == 0)
    {
        [self addSubview:self.button20];
        [self addSubview:self.button21];
        [self addSubview:self.button22];
        [self addSubview:self.button23];
        [self addSubview:self.button24];
    
        [self addSubview:self.button30];
        [self addSubview:self.button31];
        [self addSubview:self.button32];
        [self addSubview:self.button33];
    
        [self addSubview:self.button40];
        [self addSubview:self.button41];
    
        [self addSubview:self.button50];
    }
    
    [self addSubview:self.button60];
    
    if(type == 1)
    {
        CGRect rect = self.button02.frame;
        rect.origin.x = self.button01.frame.origin.x;
        rect.origin.y = self.button01.frame.origin.y;
        self.button02.frame = rect;
        self.button60.frame = self.button20.frame;
    }
    
    [self.allButtons addObject:self.button00];
    [self.allButtons addObject:self.button01];
    [self.allButtons addObject:self.button02];
    [self.allButtons addObject:self.button10];
    [self.allButtons addObject:self.button11];
    [self.allButtons addObject:self.button12];
    [self.allButtons addObject:self.button13];
    [self.allButtons addObject:self.button20];
    [self.allButtons addObject:self.button21];
    [self.allButtons addObject:self.button22];
    [self.allButtons addObject:self.button23];
    [self.allButtons addObject:self.button24];
    [self.allButtons addObject:self.button30];
    [self.allButtons addObject:self.button31];
    [self.allButtons addObject:self.button32];
    [self.allButtons addObject:self.button33];
//    [self.allButtons addObject:self.button34];
    [self.allButtons addObject:self.button50];
    [self.allButtons addObject:self.button40];
    [self.allButtons addObject:self.button41];
    [self.allButtons addObject:self.button60];
}

- (void)clickButtton:(UIButton*)sender{
    if([sender isSelected]){
        [self setSelectedOff:sender];
    }else{
        [self setSelectedOn:sender];
    }
    if (self.type == 0) {
        NSArray *payTypes = @[@"2",@"7",@"8",@"9",@"10",@"11",@"17",@"18"];
        NSInteger index = [self.allButtons indexOfObject:sender];
        
        if (self.selectedIndexs.count) {
            if ([ICrEAMTool array:self.selectedIndexs hasItemInOtherArray:payTypes]) {
                if (![payTypes containsObject:[@(index) stringValue]]){
                    if (!self.isGetCar) {
                        sender.selected = NO;
                        [[NSNotificationCenter defaultCenter] postNotificationName:@"payTypesWrong" object:nil];
                        if ([self.currentSelectedData containsObject:sender.titleLabel.text]){
                            [self.currentSelectedData removeObject:sender.titleLabel.text];
                        }
                        return;
                    }
                }
            }else{
                if ([payTypes containsObject:[@(index) stringValue]]){
                    if (!self.isGetCar) {
                        sender.selected = NO;
                        [[NSNotificationCenter defaultCenter] postNotificationName:@"payTypesWrong" object:nil];
                        if ([self.currentSelectedData containsObject:sender.titleLabel.text]){
                            [self.currentSelectedData removeObject:sender.titleLabel.text];
                        }
                        return;
                    }
                    
                }
            }
        }
        
        
        if (sender.isSelected && ![self.selectedIndexs containsObject:[@(index) stringValue]]) {
            [self.selectedIndexs addObject:[@(index) stringValue]];
        }
        if (!sender.isSelected && [self.selectedIndexs containsObject:[@(index) stringValue]]) {
            [self.selectedIndexs removeObject:[@(index) stringValue]];
        }
    }
    
    //log
    NSMutableString *temp = [[NSMutableString alloc]initWithString:@"当前选择:"];
    for(NSString *data in self.currentSelectedData){
        [temp appendString:data];
        [temp appendString:@","];
    }
    [[NSNotificationCenter defaultCenter] postNotificationName:@"RepairTypeChanged" object:@{@"isAdd":[NSNumber numberWithBool:[sender isSelected]],@"repairName":sender.titleLabel.text}];
}

-(void)setSelectedOn:(UIButton*)sender{
    
    //代理 判断是否可添加
    if(self.type == 1)
    {
        if([self.delegate respondsToSelector:@selector(canAddItem:)])
        {
            if([self.delegate canAddItem:sender.titleLabel.text])
            {
                [sender setSelected:YES];
                if (![self.currentSelectedData containsObject:sender.titleLabel.text]){
                    [self.currentSelectedData addObject:sender.titleLabel.text];
                }
            }
        }
    }
    else
    {
        [sender setSelected:YES];
        
        if (![self.currentSelectedData containsObject:sender.titleLabel.text]){
            [self.currentSelectedData addObject:sender.titleLabel.text];
        }
    }
    

}


-(void)setSelectedOff:(UIButton*)sender{
    //代理 判断是否可删除
    if(self.type == 1)
    {
        if([self.delegate respondsToSelector:@selector(canRemoveItem:)])
        {
            if([self.delegate canRemoveItem:sender.titleLabel.text])
            {
                [sender setSelected:NO];
                
                if([self.currentSelectedData containsObject:sender.titleLabel.text])
                {
                    [self.currentSelectedData removeObject:sender.titleLabel.text];
                    
                }
            }
        }
    }
    else
    {
        if ([self.delegate respondsToSelector:@selector(canRemoveItem:)]) {
            if ([self.delegate canRemoveItem:sender.titleLabel.text]) {
                [sender setSelected:NO];
                
                if([self.currentSelectedData containsObject:sender.titleLabel.text])
                {
                    [self.currentSelectedData removeObject:sender.titleLabel.text];
                    
                }
            }
        } else {
            [sender setSelected:NO];
            
            if([self.currentSelectedData containsObject:sender.titleLabel.text])
            {
                [self.currentSelectedData removeObject:sender.titleLabel.text];
                
            }
        }
    }
    
    
    
}
//设置初始化选择状态
- (BOOL)checkInitSelectedStatusWithContent:(NSString *)data{
    if([self.currentSelectedData containsObject:data])
        return true;
    else
        return false;
}
-(CGRect)getRectByContentNum:(int) num andStartX:(int)startX andStartY:(int)startY{
    int width;
    
    switch (num) {
        case 4:
            width = ActualWidth(75);
            break;
        case 5:
            width = ActualWidth(85);
            break;
        case 6:
            width = ActualWidth(100);
            break;
        case 7:
            width = ActualWidth(130);
            break;
        default:
            break;
    }
    
    return CGRectMake(startX, startY, width, ActualHeight(38));
}
-(CGSize)getSizeByContentNum:(int)num{
    CGSize size;
    switch (num) {
        case 4:
            size = CGSizeMake(ActualWidth(75), ActualHeight(40));
            break;
        case 5:
             size = CGSizeMake(ActualWidth(90), ActualHeight(40));
            break;
        case 6:
             size = CGSizeMake(ActualWidth(110), ActualHeight(40));
            break;
        case 7:
             size = CGSizeMake(ActualWidth(140), ActualHeight(40));
            break;
        default:
            break;
    }
    return size;
}

- (NSMutableArray *)allButtons{
    if (!_allButtons) {
        _allButtons = [NSMutableArray array];
    }
    return _allButtons;
}

- (NSMutableArray *)selectedIndexs{
    if (!_selectedIndexs) {
        _selectedIndexs = [NSMutableArray array];
    }
    return _selectedIndexs;
}

-(UIButton *)button00{
    if(!_button00){
        CGRect rect = [self getRectByContentNum:4 andStartX:STARTLEFT andStartY:STARTTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button00 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];

        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button00 setUpButtonWithNormolTitle:@"常规保养" selectedTitle:@"常规保养"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"常规保养"] == YES){
            [_button00 setSelected:YES];
            [self.selectedIndexs addObject:@"0"];
        }
        
        
    }
    return _button00;
}
-(UIButton *)button01{
    if(!_button01){
        CGRect rect = [self getRectByContentNum:4 andStartX:self.button00.rightEdge+MARGINRIGHT andStartY:STARTTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button01 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button01 setUpButtonWithNormolTitle:@"快速保养" selectedTitle:@"快速保养"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"快速保养"] == YES){
            [_button01 setSelected:YES];
            [self.selectedIndexs addObject:@"1"];
        }
        
        
    }
    return _button01;
}
-(UIButton *)button02{
    if(!_button02){
        CGRect rect = [self getRectByContentNum:6 andStartX:([ICrEAMTool isVW]?self.button00.rightEdge:self.button01.rightEdge)+MARGINRIGHT andStartY:STARTTOP];
        CGSize size = [self getSizeByContentNum:6];
        _button02 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button02 setUpButtonWithNormolTitle:@"质量担保保养" selectedTitle:@"质量担保保养"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"质量担保保养"] == YES){
            [_button02 setSelected:YES];
            [self.selectedIndexs addObject:@"2"];
        }
        
        
    }
    return _button02;
}
-(UIButton *)button10{
    if(!_button10){
        CGRect rect = [self getRectByContentNum:4 andStartX:STARTLEFT andStartY:self.button00.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button10 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button10 setUpButtonWithNormolTitle:@"一般维修" selectedTitle:@"一般维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"一般维修"] == YES){
            [_button10 setSelected:YES];
            [self.selectedIndexs addObject:@"3"];
        }
        
        
    }
    return _button10;
}
-(UIButton *)button11{
    if(!_button11){
        CGRect rect = [self getRectByContentNum:4 andStartX:self.button10.rightEdge+MARGINRIGHT andStartY:self.button00.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button11 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button11 setUpButtonWithNormolTitle:@"延保维修" selectedTitle:@"延保维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"延保维修"] == YES){
            [_button11 setSelected:YES];
            [self.selectedIndexs addObject:@"4"];
        }
        
        
    }
    return _button11;
}
-(UIButton *)button12{
    if(!_button12){
        CGRect rect = [self getRectByContentNum:4 andStartX:self.button11.rightEdge+MARGINRIGHT andStartY:self.button00.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button12 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button12 setUpButtonWithNormolTitle:@"附件安装" selectedTitle:@"附件安装"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"附件安装"] == YES){
            [_button12 setSelected:YES];
            [self.selectedIndexs addObject:@"5"];
        }
        
        
    }
    return _button12;
}
-(UIButton *)button13{
    if(!_button13){
        CGRect rect = [self getRectByContentNum:7 andStartX:self.button12.rightEdge+MARGINRIGHT andStartY:self.button00.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:7];
        _button13 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button13 setUpButtonWithNormolTitle:@"二手车认证维修" selectedTitle:@"二手车认证维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"二手车认证维修"] == YES){
            [_button13 setSelected:YES];
            [self.selectedIndexs addObject:@"6"];
        }
        
        
    }
    return _button13;
}
-(UIButton *)button20{
    if(!_button20){
        CGRect rect = [self getRectByContentNum:4 andStartX:STARTLEFT andStartY:self.button10.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button20 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button20 setUpButtonWithNormolTitle:@"普通索赔" selectedTitle:@"普通索赔"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"普通索赔"] == YES){
            [_button20 setSelected:YES];
            [self.selectedIndexs addObject:@"7"];
        }
        
        
    }
    return _button20;
}
-(UIButton *)button21{
    if(!_button21){
        CGRect rect = [self getRectByContentNum:5 andStartX:self.button20.rightEdge+MARGINRIGHT andStartY:self.button10.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:5];
        _button21 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button21 setUpButtonWithNormolTitle:@"PDI 索赔" selectedTitle:@"PDI 索赔"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"PDI 索赔"] == YES){
            [_button21 setSelected:YES];
            [self.selectedIndexs addObject:@"8"];
        }
        
        
    }
    return _button21;
}
-(UIButton *)button22{
    if(!_button22){
        CGRect rect = [self getRectByContentNum:4 andStartX:self.button21.rightEdge+MARGINRIGHT andStartY:self.button10.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button22 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button22 setUpButtonWithNormolTitle:[ICrEAMTool isVW]?@"优惠索赔":@"优惠维修" selectedTitle:[ICrEAMTool isVW]?@"优惠索赔":@"优惠维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:[ICrEAMTool isVW]?@"优惠索赔":@"优惠维修"] == YES){
            [_button22 setSelected:YES];
            [self.selectedIndexs addObject:@"9"];
        }
        
    }
    return _button22;
}
-(UIButton *)button23{
    if(!_button23){
        CGRect rect = [self getRectByContentNum:4 andStartX:self.button22.rightEdge+MARGINRIGHT andStartY:self.button10.bottomEdge+MARGINTOP];
        
        CGSize size = [self getSizeByContentNum:4];
        _button23 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button23 setUpButtonWithNormolTitle:@"受控索赔" selectedTitle:@"受控索赔"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        
        if([self checkInitSelectedStatusWithContent:@"受控索赔"] == YES){
            [_button23 setSelected:YES];
            [self.selectedIndexs addObject:@"10"];
        }
        
    }
    return _button23;
}
-(UIButton *)button24{
    if(!_button24){
        CGRect rect = [self getRectByContentNum:4 andStartX:self.button23.rightEdge+MARGINRIGHT andStartY:self.button10.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button24 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button24 setUpButtonWithNormolTitle:@"三包维修" selectedTitle:@"三包维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        
        if([self checkInitSelectedStatusWithContent:@"三包维修"] == YES){
            [_button24 setSelected:YES];
            [self.selectedIndexs addObject:@"11"];
        }
        
        
    }
    return _button24;
}
-(UIButton *)button30{
    if(!_button30){
        CGRect rect = [self getRectByContentNum:6 andStartX:STARTLEFT andStartY:self.button21.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:6];
        _button30 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button30 setUpButtonWithNormolTitle:@"内部车辆维修" selectedTitle:@"内部车辆维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"内部车辆维修"] == YES){
            [_button30 setSelected:YES];
            [self.selectedIndexs addObject:@"12"];
        }
    }
    return _button30;
}
-(UIButton *)button31{
    if(!_button31){
        CGRect rect = [self getRectByContentNum:6 andStartX:self.button30.rightEdge+MARGINRIGHT andStartY:self.button21.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:6];
        _button31 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button31 setUpButtonWithNormolTitle:@"内部返工维修" selectedTitle:@"内部返工维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"内部返工维修"] == YES){
            [_button31 setSelected:YES];
            [self.selectedIndexs addObject:@"13"];
        }
        
    }
    return _button31;
}

- (UIButton *)button32{
    if(!_button32){
        CGRect rect = [self getRectByContentNum:6 andStartX:self.button31.rightEdge+MARGINRIGHT andStartY:self.button21.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:6];
        _button32 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button32 setUpButtonWithNormolTitle:@"外部返工维修" selectedTitle:@"外部返工维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"外部返工维修"] == YES){
            [_button32 setSelected:YES];
            [self.selectedIndexs addObject:@"14"];
        }
        
    }
    return _button32;
}

- (UIButton *)button33{
    if(!_button33){
        CGRect rect = [self getRectByContentNum:6 andStartX:self.button32.rightEdge+ActualWidth(10) andStartY:self.button21.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:5];
        _button33 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button33 setUpButtonWithNormolTitle:@"售前车辆维修" selectedTitle:@"售前车辆维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"售前车辆维修"] == YES){
            [_button33 setSelected:YES];
            [self.selectedIndexs addObject:@"15"];
        }
        
    }
    return _button33;
}

- (UIButton *)button40{
    if(!_button40){
        CGRect rect = [self getRectByContentNum:4 andStartX:STARTLEFT andStartY:self.button50.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button40 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button40 setUpButtonWithNormolTitle:@"召回行动" selectedTitle:@"召回行动"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"召回行动"] == YES){
            [_button40 setSelected:YES];
            [self.selectedIndexs addObject:@"17"];
        }
        
    }
    return _button40;
}

- (UIButton *)button41{
    if(!_button41){
        CGRect rect = [self getRectByContentNum:4 andStartX:self.button40.rightEdge+MARGINRIGHT andStartY:self.button50.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:7];
        _button41 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button41 setUpButtonWithNormolTitle:@"技术活动" selectedTitle:@"技术活动"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"技术活动"] == YES){
            [_button41 setSelected:YES];
            [self.selectedIndexs addObject:@"18"];
        }
        
    }
    return _button41;
}

- (UIButton *)button50{
    if(!_button50){
        CGRect rect = [self getRectByContentNum:6 andStartX:STARTLEFT andStartY:self.button30.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:6];
        _button50 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button50 setUpButtonWithNormolTitle:@"事故车维修" selectedTitle:@"事故车维修"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        if([self checkInitSelectedStatusWithContent:@"事故车维修"] == YES){
            [self.selectedIndexs addObject:@"16"];
            [_button50 setSelected:YES];
        }
        
        
    }
    return _button50;
}
- (UIButton *)button60{
    if(!_button60){
        CGRect rect = [self getRectByContentNum:4 andStartX:STARTLEFT andStartY:self.button40.bottomEdge+MARGINTOP];
        CGSize size = [self getSizeByContentNum:4];
        _button60 = [[UIButton alloc]initWithFrame:rect];
        
        UIImage *normalBac = [ICrEAMTool imageWithColor:Color(0xF2F2F2) size:size];
        
        UIImage *selectedBac = [ICrEAMTool imageWithColor:TitleColor size:size];
        [_button60 setUpButtonWithNormolTitle:@"服务活动" selectedTitle:@"服务活动"  normolTitleSize:TitleSize selectedTitleSize:TitleSize normolTitleColor:Color(0xA1A1A1) selectedTitleColor: Color(0xFFFFFF) normolBcakImage:normalBac selectedBackImage:selectedBac actionSEL:@selector(clickButtton:) target:self];
        
        if([self checkInitSelectedStatusWithContent:@"服务活动"] == YES){
            [_button60 setSelected:YES];
            [self.selectedIndexs addObject:@"19"];
        }
        
    }
    return _button60;
}

- (NSMutableArray *)currentSelectedData{

    if(!_currentSelectedData){
        
        _currentSelectedData = [[NSMutableArray alloc] init];
        
    }
    
    return _currentSelectedData;
}

- (NSMutableArray *)getSelectedData{
    return self.currentSelectedData;
}

@end

